pub fn convert_base(num_str: &str, to_base: u32) -> String {
    // 暂只考虑最大16进制
    let _num_charactor = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
    let _low_charactor = ["a", "b", "c", "d", "e", "f", "g"];
    let _num_str = num_str.replace(")", "");
    let _tmp: Vec<&str> = _num_str.split("(").collect();

    let _num = *(_tmp.get(0).unwrap());
    let _source_base = (*(_tmp.get(1).unwrap())).parse::<i32>().unwrap();
    let _target_base = to_base as i32;
    // dbg!(_source_base);
    // dbg!(_num);
    // dbg!(_target_base);
    // 10进制值,标准被除数
    let mut _std_num = std_num(_source_base, _num);
    //dbg!(_std_num);
    // 所有base的0次幂都等于1
    let mut max_pow_num = 1;
    let mut max_pow = 0;
    // 要找最小的位，满足，位对应的进制值(base的n次幂) > 10进制值
    while max_pow_num <= _std_num {
        max_pow = max_pow + 1;
        max_pow_num = pow(_target_base, max_pow)
    }

    let mut _tmp_result: Vec<i32> = vec![];
    // max_pow_num is divisor
    let mut _quotient = 0;
    //dbg!(max_pow);
    if max_pow > 0 {
        max_pow = max_pow - 1;
    } else {
        max_pow = 0;
    }
    // max_pow == 0 ?
    if max_pow == 0 {
        _tmp_result.push(_std_num);
    }

    // 循环确定结果的每位的值
    while max_pow > 0 {
        max_pow_num = pow(_target_base, max_pow);
        //dbg!(max_pow_num);
        _quotient = _std_num / max_pow_num;
        _std_num = _std_num % max_pow_num;
        //dbg!(quotient);
        _tmp_result.push(_quotient);
        max_pow = max_pow - 1;
        if max_pow == 0 {
            _tmp_result.push(_std_num);
            break;
        }
    }
    //dbg!(&_tmp_result);
    let tmp_str: Vec<&str> = _tmp_result
        .into_iter()
        .map(|i| -> &str {
            if i < 10 {
                _num_charactor.get(i as usize).unwrap()
            } else {
                *(_low_charactor.get((i - 10) as usize).unwrap())
            }
        })
        .collect();
    tmp_str.concat()
}

fn std_num(base: i32, num: &str) -> i32 {
    if base == 10 {
        num.parse::<i32>().unwrap()
    } else {
        // dbg!(num);
        let num: Vec<char> = num.chars().collect();
        let mut l = num.len() - 1;
        let mut sum: i32 = 0;
        while l > 0 {
            // dbg!(l);
            sum = sum + check_charactor(num.get(l).unwrap()) * pow(base, (num.len() - 1) - l);
            l = l - 1;
            if l == 0 {
                sum = sum + check_charactor(num.get(l).unwrap()) * pow(base, (num.len() - 1) - l);
                break;
            }
        }
        sum
    }
}

fn check_charactor(c: &char) -> i32 {
    let c = *c;
    if c.is_numeric() {
        c.to_string().parse::<i32>().unwrap()
    } else {
        let d = c.to_string();
        let tmp = match d.as_str() {
            "a" => 10,
            "b" => 11,
            "c" => 12,
            "d" => 13,
            "e" => 14,
            "f" => 15,
            "g" => 16,
            _ => 0,
        };
        tmp
    }
}

fn pow(base: i32, power: usize) -> i32 {
    if power == 0 {
        1
    } else {
        let mut _v = base;
        let mut _t = power;
        while _t > 1 {
            _v = _v * base;
            _t = _t - 1;
        }
        _v
    }
}
